package yinghan;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JTextArea;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.LinkedList;
import java.awt.event.ActionEvent;

public class zz extends JFrame {

	private JPanel contentPane;
	private JTextField input;

    private LinkedList<record>content=new LinkedList<record>();
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					zz frame = new zz();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public zz() {
		record r[]=new record[2];
		r[0]=new record("hello","");
		r[1]=new record("world","");
		for(record i:r)
			content.add(i);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		input = new JTextField();
		input.setBounds(61, 20, 300, 80);
		contentPane.add(input);
		input.setColumns(10);
		JTextArea output = new JTextArea();
		output.setBounds(73, 160, 300, 80);
		contentPane.add(output);
		JButton search = new JButton("search");
		search.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String str=input.getText();
				
				Iterator<record>it=content.iterator();
				record re;
				boolean flag=true;
				while(it.hasNext()) {
					re=it.next();
					if(re.english.equals(str)) {
						 flag = false;
						output.setText(re.chinese);
					}
					if(re.chinese.equals(str)) {
						flag=false;
						output.setText(re.english);
					}
				}
				if(flag) {
					output.setText("ûҵ");
				}}
			
		});
		search.setBounds(156, 110, 97, 23);
		contentPane.add(search);
		
		
	}
}
